/**
 * @fileOverview 腾讯视频JS库 html5大图
 * @lastUpdate $Date: 2011-01-19 18:59:28 +0800 (星期三, 2011-01-19) $
 * @author QQLive $LastChangedBy: vicyao $
 * @version $Rev: 6889 $
 */

/**
 * 腾讯视频JS库 html5大图
 */
Live.txv.html5pic = {
	/**
	 * 参数
	 */
	config : {
		/**
		 * 容器ID
		 */
		containerId : null,
		/**
		 * html内容地址
		 */
		url : null,
		/**
		 * item选择条件，如".mod_item"
		 */
		itemSel : null,
		/**
		 * itme个数
		 */
		itemCount : 5
	},
	init : function(cfg){
		QZFL.object.extend(this.config, cfg);
		
		if (!txv.common.useHtml5()){
			return;
		}
		//QZFL.console.print("change");
		$e("#" + txv.html5pic.config.containerId).load(txv.html5pic.config.url, function(){
			txv.html5pic.bindAni();
		});
	},
	bindAni : function(){
		var div = $e("#" + txv.html5pic.config.containerId + " div").elements[0];
		var prev = $e(".prev", div);
		var next = $e(".next", div);
		
		function reset(){
			var items = $e(div).find(txv.html5pic.config.itemSel);
			items.unBind("click");
			var midIndex = Math.floor(txv.html5pic.config.itemCount/2);
			for (var i=0;i<txv.html5pic.config.itemCount;i++){
				if (i<midIndex){
					items.get(i).bind("click", function(e){
						if ( e && e.preventDefault ) 
							//阻止默认浏览器动作(W3C) 
							e.preventDefault(); 
						onPrev();
						return false;
					});
				}
				else if (i>midIndex){
					items.get(i).bind("click", function(e){
						if ( e && e.preventDefault ) 
							//阻止默认浏览器动作(W3C) 
							e.preventDefault(); 
						onNext();
						return false;
					});
				}
			}			
		};
		
		function onPrev() {
			//QZFL.console.print("prev");
			var pic = $e(div).find(txv.html5pic.config.itemSel).elements[txv.html5pic.config.itemCount-1];
			div.insertBefore(pic.cloneNode(true),div.firstChild);
			div.removeChild(pic);
			reset();
		};
		function onNext() {
			//QZFL.console.print("next");
			var pic = $e(div).find(txv.html5pic.config.itemSel).elements[0];
			div.insertBefore(pic.cloneNode(true), prev.elements[0]);
			div.removeChild(pic);
			reset();
		};
		
		reset();
		
		prev.bind("click", function(){
			onPrev();
		});
		
		next.bind("click", function(){
			onNext();
		});		
	}
	
};
/**
 * @fileOverview 腾讯视频JS库 精彩瞬间
 * @lastUpdate $Date: 2010-12-30 09:39:53 +0800 (星期四, 2010-12-30) $
 * @author QQLive $LastChangedBy: vicyao $
 * @version $Rev: 6621 $
 */

/**
 * 腾讯视频JS库 精彩瞬间
 * 
 * @namespace Live.txv.amazing
 * @type {Object}
 */
Live.txv.amazing = {
	/**
	 * 
	 */
	init: function(){
		var cur = "current";
		var li = $e("#amazinglt li");
//		li.bind("mouseout", function(){
//			if (this.className.indexOf("current")>=0){
//				$e(this).removeClass(cur);
//			}
//		});
		//li.get(2).addClass(cur);
		li.bind("mouseover", function(){
			if (this.className.indexOf("current")<0){
				$e("#amazinglt .current").removeClass(cur);
				$e(this).addClass(cur);
			}
		});
		var pageSize = 5;
		var si = new Live.SimpleImgShow();
		si.init({
			isPolish : false,
			showCnt : pageSize,
			items : li,
			playLeft : $e("#amazing .prev"),
			playRight : $e("#amazing .next"),
			onchange : function(istart, iend, curPage){
				$e("#amazinglt .current").removeClass(cur);
				txv.log(Math.floor((iend+istart)/2));
				li.get(Math.floor((iend+istart)/2)).addClass(cur);
//				if (iend - istart >= pageSize-1){
//					
//				}
//				else{
//					
//				}
			}
		});
	}

};

/**
 * 通用广告动画效果 兼容目前各种主流浏览器
 * 
 * @class Live.ContentSlider
 */
Live.ContentSlider = function() {
	/**
	 * 配置项
	 * 
	 * @type {Object}
	 */
	this.config = {
		/**
		 * 切换响应的鼠标事件
		 * 
		 * @type String
		 */
		revealtype : "mouseover",
		/**
		 * 是否自动播放
		 * 
		 * @type Boolean
		 * @default true
		 */
		autoPlay : true,
		/**
		 * 自动播放间隔,单位毫秒
		 * 
		 * @type Number
		 */
		autoPlayInterval : 5000,
		/**
		 * 自动播放鼠标延迟,单位毫秒
		 * 
		 * @type Number
		 */
		mouseEvtDelay : 300,
		/**
		 * 图片元素QZFL的selector
		 * 
		 * @type String
		 */
		imgItems : null,
		/**
		 * 图片容器QZFL的selector
		 */
		imgContainer : null,
		/**
		 * 标题
		 */
		titleItems : null,
		/**
		 * 文字内容QZFL的selector
		 */
		textItems : "",
		/**
		 * "上一个"按钮
		 */
		prevBtn : "",
		/**
		 * "下一个"按钮
		 */
		nextBtn : "",
		/**
		 * 翻页的QZFL的selector
		 * 
		 * @type String
		 */
		pageItems : "",
		/**
		 * 渐隐渐现延迟
		 * 
		 * @type Number
		 */
		fadeUpDelay : 100,
		/**
		 * 控制区
		 */
		ctrlPanel : null,
		/**
		 * 大按钮
		 */
		enterBtn : null,
		/**
		 * 按钮样式列表
		 */
		btnClass : [],
		/**
		 * 渐隐渐现cover层
		 */
		fadeCover : null,
		/**
		 * 是否需要循环切换
		 */
		loop : false,
		/**
		 * 当前播放的内容项的索引
		 * 
		 * @type Number
		 * @ignore
		 */
		cssChoose : "current",
		/**
		 * 是否设置图片显示css是否全部按照cssChoose来展示（默认false是display:;）
		 */
		AllCssChoose : false,
		index : 0
	},
	/**
	 * 时间计数器资源池
	 * 
	 * @type
	 * @ignore
	 */
	_times = {};

	/**
	 * 透明度
	 * 
	 * @type Number
	 * @ignore
	 */
	_opacity = 0.1;
};
Live.ContentSlider.prototype = {
	/**
	 * 初始化动画对象
	 * 
	 * @param {Object}
	 *          _config 配置
	 */
	init : function(_config) {
		this.config.fadeCover = $("fadecover");
		for (var prop in _config) {
			this.config[prop] = _config[prop];
		}
		var self = this;
		if (!!this.config.pageItems) {
			this.config.pageItems.each(function(el, i) {
						var $el = $e(el);
						$el.attr("hideFocus", "true");
						if (self.config.revealtype == "mouseover") {
							$el.bind("mouseover", function() {
										clearTimeout(_times.autoPlayItv);
										clearTimeout(_times.mouseEvtDelay);
										_times.mouseEvtDelay = setTimeout(function() {
													self.play(i, true);
												}, self.config.mouseEvtDelay);
									});
							$el.bind("mouseout", function() {
										clearTimeout(_times.mouseEvtDelay);
										_times.autoPlayItv = setInterval(function() {
													self.play();
												}, self.config.autoPlayInterval);
									});
							$el.bind("click", function() {
										clearTimeout(_times.autoPlayItv);
										clearTimeout(_times.mouseEvtDelay);
										self.play(i, true);
										
									});
						}
					});
		}
		if (!!this.config.nextBtn) {
			this.config.nextBtn.attr("hideFocus", "true");
			this.config.nextBtn.bind("mouseup", function() {
						self.playNext();
					});
		}
		if (!!this.config.prevBtn) {
			this.config.prevBtn.attr("hideFocus", "true");
			this.config.prevBtn.bind("mouseup", function() {
						self.playPrev();
					});
		}
		_times.autoPlayItv = setInterval(function() {
					self.play();
				}, self.config.autoPlayInterval);
		this.showEnterBtn(0);
		if (!!this.config.imgItems) {
			
		}
		if (!!this.config.titleItems) {
			this.config.titleItems.attr("hideFocus", "true");
		}
		if (!!this.config.ctrlPanel) {
			if (typeof this.config.ctrlPanel.effectShow == "function") {
				this.config.ctrlPanel.effectShow();
			}
			else {
				this.config.ctrlPanel.show();
			}
		}
		this.setPrevBtn();
		this.setNextBtn();
	},
	/**
	 * 对象变换
	 * 
	 * @param {Number}
	 *          index 图片索引
	 */
	elementChange : function(index) {
		if(this.config.AllCssChoose){
			this.config.imgItems.removeClass(this.config.cssChoose);
			if (this.config.index < this.config.imgItems.size()) {
				this.config.imgItems.get(this.config.index).addClass(this.config.cssChoose);
			}
			this.config.textItems.removeClass(this.config.cssChoose);
			if (this.config.index < this.config.textItems.size()) {
				this.config.textItems.get(this.config.index).addClass(this.config.cssChoose);
			}
		}
		else{
			if (!!this.config.imgItems)
				this.config.imgItems.hide();
			if (!!this.config.textItems)
				this.config.textItems.hide();
			if (!!this.config.imgItems && this.config.index < this.config.imgItems.size())
				this.config.imgItems.get(this.config.index).show();
			if (!!this.config.textItems && this.config.index < this.config.textItems.size())
				this.config.textItems.get(this.config.index).show();
		}
		if (!!this.config.pageItems) {
			this.config.pageItems.removeClass(this.config.cssChoose);
			if (this.config.index < this.config.pageItems.size()) {
				this.config.pageItems.get(this.config.index).addClass(this.config.cssChoose);
			}
		}
		this.showEnterBtn(index);
		var targetObject = this.config.fadeCover;
		if (!targetObject)
			return;
		_opacity = 0.9;
		targetObject.style.display = "";
		this.fadeUp(targetObject);
		this.setNextBtn();
		this.setPrevBtn();
	},
	/**
	 * 显示进入按钮
	 * 
	 * @param {Number}
	 *          index 按钮索引
	 */
	showEnterBtn : function(index) {
		if (!!this.config.enterBtn) {
			if (!!this.config.btnClass && typeof this.config.btnClass[index] != "undefined") {
				if (this.config.btnClass[index] != false) {
					this.config.enterBtn.attr("className", this.config.btnClass[index] == 1 ? "play" : "detail");
					this.config.enterBtn.show();
					this.config.enterBtn.unBind("click");
					var self = this;
					this.config.enterBtn.bind("click", function() {
								var u = self.config.imgItems.get(index).find("a").attr("href");
								if (u == "")
									return;
								var tar = "_blank";
								if (u.indexOf("/cover/") >= 0)
									tar = "coverp";
								if (Live.webqq.isWebQQ()) {
									tar = "_self";
								}
								window.open(u, tar);
								//Live.tj2.hot("INDEX.FOCUS.ENTERBTN");
							})
				}
				else {
					this.config.enterBtn.hide();
				}
			}
			else {
				this.config.enterBtn.hide();
			}
		}
	},
	/**
	 * 播放动画
	 * 
	 * @param {Number}
	 *          index 播放内容的索引
	 */
	play : function(index, isStop) {
		if (index == this.config.index)
			return;
		if (!this.config.imgItems)
			return;
		isStop = typeof isStop == "undefined" ? false : isStop;
		if (typeof index != "undefined") {
			this.config.index = index;
			clearInterval(_times.autoPlayItv);
			_times.autoPlayItv = -1;
			if (this.config.loop == true) {
				this.config.index = this.config.index >= this.config.imgItems.size() ? 0 : this.config.index;
				this.config.index = this.config.index < 0 ? this.config.imgItems.size() - 1 : this.config.index;
			}
		}
		else {
			this.config.index = this.config.index < this.config.imgItems.elements.length - 1 ? this.config.index + 1 : 0;
			this.config.index = this.config.index < 0 ? 0 : this.config.index;
		}
		var $curImg = this.config.imgItems.get(this.config.index).find("img");
		var self = this;
		if (($curImg.getAttr("src") == "" || $curImg.getAttr("src") == null)) {
			var done = false;
			var img = new Image();
			img.onload = img.onreadystatechange = function() {
				if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
					done = true;
					$curImg.setAttr("src", $curImg.elements[0].getAttribute("_src"));
					self.elementChange(self.config.index);
					delete img;
					img = null;
				}
			};
			img.onerror = function() {
				self.elementChange(self.config.index);
				delete img;
				img = null;
			};
			img.src = $curImg.elements[0].getAttribute("_src");
		}
		else {
			this.elementChange(self.config.index);
		}
		if (isStop == false && _times.autoPlayItv == -1) {
			var self = this;
			_times.autoPlayItv = setInterval(function() {
						self.play();
					}, self.config.autoPlayInterval);
		}
	},
	/**
	 * 是否可以播放下一张
	 * 
	 * @return {Boolean}
	 * @ignore
	 */
	canPlayNext : function() {
		if (this.config.loop == true)
			return true;
		return !(this.config.index == this.config.imgItems.elements.length - 1);
	},
	/**
	 * 是否可以播放上一张
	 * 
	 * @return {Boolean}
	 * @ignore
	 */
	canPlayPrev : function() {
		if (this.config.loop == true)
			return true;
		return !(this.config.index == 0);
	},
	/**
	 * 设置“下一个”按钮状态
	 * 
	 * @ignore
	 */
	setNextBtn : function() {
		if (!this.config.nextBtn)
			return;
		if (this.canPlayNext() == true) {
			this.config.nextBtn.removeClass("over");
		}
		else {
			this.config.nextBtn.addClass("over");
		}
	},
	/**
	 * 设置“上一个”按钮状态
	 * 
	 * @ignore
	 */
	setPrevBtn : function() {
		if (!this.config.prevBtn)
			return;
		if (this.canPlayPrev() == true) {
			this.config.prevBtn.removeClass("over");
		}
		else {
			this.config.prevBtn.addClass("over");
		}
	},
	/**
	 * 播放下一个
	 */
	playNext : function() {
		if (!this.canPlayNext())
			return;
		this.play(this.config.index + 1, false);
	},
	/**
	 * 播放上一个
	 */
	playPrev : function() {
		if (!this.canPlayPrev())
			return;
		this.play(this.config.index - 1, false);
	},
	/**
	 * 渐现效果
	 * 
	 * @param {Object}
	 *          targetobject 渐显层对象
	 */
	fadeUp : function(targetobject) {
		var self = this;
		if (_opacity > 0) {
			clearTimeout(_times.fadeUp);
			this.setopacity(targetobject, _opacity - 0.1);
			_times.fadeUp = setTimeout(function() {
						self.fadeUp(targetobject);
					}, self.config.fadeUpDelay);
		}
		else {
			// targetobject.style.filter = "";
			targetobject.style.display = "none";
		}
	},
	/**
	 * 设置透明度(兼容IE5.5~IE8,FF,Safair,Chrome,Opera,W3C)
	 * 
	 * @param {Object}
	 *          targetobject 要设置的对象
	 * @param {Number}
	 *          value 透明度值范围为0.0~1.0
	 */
	setopacity : function(targetobject, value) {
		if (!!Live.userAgent.ie) {
			targetobject.style.filter = "alpha(opacity=" + value * 100 + ")";
		}
		else if (typeof targetobject.style.MozOpacity != "undefined") { // Old Mozilla
			targetobject.style.MozOpacity = value;
		}
		else if (typeof targetobject.style.opacity != "undefined") { // Standard opacity
			targetobject.style.opacity = value;
		}
		_opacity = value;
	}
};


Live.txv.music_index = {
	pageNum : 0,
	pager:null,
	/**
	 * 
	 */
	init: function(totalPage){
		txv.common.initPage({watch:true});
		this.initAmazing();
		txv.music_index.pageNum = totalPage;

		var ad = new Live.ContentSlider();
		ad.init({
			imgItems : $e(".mod_focus_pic li"), // 图片集合
			textItems : $e(".mod_focus_text li"),// 文字集合
			imgContainer : $e(".mod_focus_pic"),// 图片集合父容器
			pageItems : $e(".mod_focus_ctrl ul li"),// 翻页小按钮集合
			ctrlPanel : $e(".mod_focus_ctrl ul"),// 控制按钮集合容器面板
			titleItems : null, // 标题集合
			fadeUpDelay : 50, // 每帧延迟
			mouseEvtDelay : 50
			});

//		var ad = new Live.ContentSlider();
//		ad.init({
//			    imgItems : $e(".vip_mod_focus_pic li"), // 图片集合
//			    textItems : $e(".vip_mod_focus_tit h3"),// 文字集合
//			    imgContainer : $e(".vip_mod_focus_pic"),// 图片集合父容器
//			    pageItems : $e(".vip_mod_focus_list li"),// 翻页小按钮集合
//			    ctrlPanel : $e(".vip_mod_focus_list"),// 控制按钮集合容器面板
//			    titleItems : $e(".vip_mod_focus_tit h3"), // 标题集合
//			    fadeUpDelay : 50, // 每帧延迟
//			    mouseEvtDelay : 50,
//			    AllCssChoose : true
//		    });

		if(txv.music_index.pager == null) {
			txv.music_index.pager = txv.music_index.createPager("pager");
			txv.music_index.setComplexPageTemplate(txv.music_index.pager);
			
			$modCont = $e("#mod_cont .mod_item");
			var totalNum = $modCont.elements.length;

			txv.music_index.pager.onTurnPage = function(page) {
				$modCont.show();
				var endNum = (page-1)*10;
				if(endNum > totalNum) endNum = totalNum;
				
				for ( var j = 0; j < endNum; j++) {
					$modCont.get(j).hide();
				}
				
				var curENum = page*10;
				if(curENum > totalNum) curEnum = totalNum;
				
				for (var j = endNum; j < curENum; j++){
					var $item = $modCont.get(j);
					if (!$item)
						return;
					
					var $img = $item.find("img");
					$img.each(function(elm){
						var src = this.getAttribute("_src");
						if (!this.getAttribute("src") && src) {
							this.style.visibility = "";
							this.setAttribute("src", src);				
						}	
					});
					$item.show();
				}
				
				for ( var j = curENum; j < totalNum; j++) {
					$modCont.get(j).hide();
				}
				txv.music_index.renderPager(txv.music_index.pager, page, txv.music_index.pageNum);
				//页面滚动最顶层
			};
			txv.music_index.renderPager(txv.music_index.pager, 1, txv.music_index.pageNum);
		}
		
	},
	initAmazing: function(){
		txv.amazing.init();
	},
	/**
	 * 初始化分页控件
	 * @param id 分页控件ID
	 * @returns 控件对象
	 */
	createPager : function(id) {
		pg = new Live.Pager();
		pg.currentPage = 1;
		pg.elmId = id;
		return pg;
	},
	/**
	 * 分页控件在页面显示
	 * @param pager 控件对象
	 * @param curPage 当前页
	 * @param totalPage 总页数
	 */
	renderPager : function(pager, curPage, totalPage) {
		pager.currentPage = curPage;
		txv.music_index.totalPage = totalPage;
		pager.init($(pager.elmId), totalPage);
		pager.fillPager();
		$e("#" + pager.elmId).show();
	},
	/**
	 * 设置复杂分页模板
	 * @param pager 控件对象
	 */
	setComplexPageTemplate : function(pager) {
		pager.Templet.PREVIOUS_DISABLE = '<span class="prev_disable prev"><span>上一页</span></span>';
		pager.Templet.PREVIOUS_ENABLE = '<a href="javascript:;" id="pager_previous_{id}" class="prev" title="上一页"><span>上一页</span></a>\n';
		pager.Templet.PAGE_NORMAL = '<a href="javascript:;" id="pager_num_{id}_{pagenum}" class="c_txt6" title="{pagenum}"><span>{pagenum}</span></a>\n';
		pager.Templet.LAST_ENABLE = '<a href="javascript:;" title="{totpage}" class="c_txt6" id="pager_last_{id}"><span>{totpage}</span></a>\n';
		pager.Templet.NEXT_DISABLE = '<span class="next_disable next"><span>下一页</span></span>\n';
		pager.Templet.NEXT_ENABLE = '<a href="javascript:;" title="下一页" id="pager_next_{id}" class="next"><span>下一页</span></a>\n';
		pager.Templet.GO_PAGE_INPUT = '';
		pager.Templet.GO_PAGE_BUTTON = '';
		pager.Templet.PAGE_COUNT = '';
	}
};

/*  |xGv00|c469a434fa9e47ce48f8dd96a4002bbd */